﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace report_demo.Data {
    public class CustomerData {
        private static CustomerData _instance;
        private String[] _columnName;

        //private String[] _categoryName;
        //private int[] _categorySum;


        private object[][] _sampleData;
        private object[][][] _complexData;

        public static CustomerData getInstance() {
            if (_instance == null) {
                _instance = new CustomerData();
            }
            return _instance;
        }
        /// <summary>
        /// 
        /// </summary>
        private CustomerData() {
            _columnName = new String[4] { "No", "Name", "Price", "Category" };
            //_categoryName = new string[4] { "FOOD", "TV", "PHONE", "AUDIO"};
            initComplexData();
            initSampleData();
            
        }
        /// <summary>
        /// 
        /// </summary>
        private void initComplexData() {
            Random rnd = new Random(1234);
            _complexData = new object[4][][];

            _complexData[0] = new object[20][];
            for (int i = 0; i < 20; i++ ) {
                object[] row = new object[4] { "" + i, "Item00" + i, rnd.Next(0, 50), "FOOD" };
                _complexData[0][i] = row;
            }
            _complexData[1] = new object[20][];
            for (int i = 0; i < 20; i++) {
                object[] row = new object[4] { "" + i, "Item00" + i, rnd.Next(500, 1000), "TV" };
                _complexData[1][i] = row;
            }
            _complexData[2] = new object[20][];
            for (int i = 0; i < 20; i++) {
                object[] row = new object[4] { "" + i, "Item00" + i, rnd.Next(100, 500), "PHONE" };
                _complexData[2][i] = row;
            }
            _complexData[3] = new object[20][];
            for (int i = 0; i < 20; i++) {
                object[] row = new object[4] { "" + i, "Item00" + i, rnd.Next(100, 300), "AUDIO" };
                _complexData[3][i] = row;
            }
            /*
            _data = new String[2][] {
                new String[4]{"1", "Michael", "abc@gmail.com", "0123456789"}, 
                new String[4]{"2", "Luke", "def@gmail.com", "9876543210"}
            };
            */
            //
        }
        private void initSampleData() {
            _sampleData = new object[80][];
            for (int i = 0; i < 20; i++) {
                _sampleData[i] = _complexData[0][i];
            }
            //
            for (int i = 0; i < 20; i++) {
                _sampleData[20+i] = _complexData[1][i];
            }
            //
            for (int i = 0; i < 20; i++) {
                _sampleData[40+i] = _complexData[2][i];
            }
            //
            for (int i = 0; i < 20; i++) {
                _sampleData[60+i] = _complexData[3][i];
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public String[] getColumnNameArray() {
            return _columnName;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public object[][] getSampleData() {
            return _sampleData;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public object[][][] getComplexData() {
            return _complexData;
        }
        /*
        public String[] getCategoryArray() {
            return _categoryName;
        }

        public int[] getCategorySum() {
            return _categorySum;
        }
        */
    }
}